package com.xinou.daily_report.controller;


import com.xinou.common.base.config.ApiResponse;
import com.xinou.common.base.database.BasePO;
import com.xinou.daily_report.PO.FruitPO;
import com.xinou.daily_report.PO.FruitUrgePO;
import com.xinou.daily_report.VO.fruit.FruitInfoVO;
import com.xinou.daily_report.VO.fruit.FruitCountVO;
import com.xinou.daily_report.VO.fruit.FruitListVO;
import com.xinou.daily_report.service.SysFruitService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author ${author}
 * @since 2021-06-11
 */
@RestController
@RequestMapping("/mini/fruit")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
@Api(tags = {"前台水果基金"})
public class MiniFruitController {

    private final SysFruitService sysFruitService;


    @PostMapping("/urge")
    @ApiOperation("催缴水果基金")
    @RequiresPermissions({"mini:fruit:urge"})
    public ApiResponse<Void> fruitUrge(@RequestBody FruitUrgePO po){
        return sysFruitService.fruitUrge(po);
    }

    @PostMapping("/urgeConfirm")
    @ApiOperation("确认催缴消息")
    @RequiresPermissions({"mini:fruit:urgeConfirm"})
    public ApiResponse<Void> fruitUrgeConfirm(){
        return sysFruitService.urgeConfirm();
    }

    @PostMapping("/list")
    @ApiOperation("获取水果基金列表")
    @RequiresPermissions({"mini:fruit:list"})
    public ApiResponse<FruitListVO> fruitList(@RequestBody FruitPO po) {
        return sysFruitService.fruitList(po);
    }

    @PostMapping("/count")
    @ApiOperation("获取水果基金统计")
    @RequiresPermissions({"mini:fruit:count"})
    public ApiResponse<FruitCountVO> fruitCount(@RequestBody FruitPO po){
        return sysFruitService.fruitCount(po);
    }

    @PostMapping("/save")
    @ApiOperation("添加水果基金")
    @RequiresPermissions({"mini:fruit:save"})
    public ApiResponse<Void> fruitSave(@RequestBody FruitPO fruitPO) {
        fruitPO.setFruitType(0);
        return sysFruitService.fruitSave(fruitPO);
    }

    @PostMapping("/getById")
    @ApiOperation("根据id查询水果基金")
    @RequiresPermissions({"mini:fruit:getById"})
    public ApiResponse<FruitInfoVO> fruitGetById(@RequestBody FruitPO fruitPO) {
        return sysFruitService.fruitGetById(fruitPO);
    }

    @PostMapping("/confirmById")
    @ApiOperation("确认")
    @RequiresPermissions({"mini:fruit:confirmById"})
    public ApiResponse<Void> fruitConfirmById(@RequestBody FruitPO fruitPO) {
        return sysFruitService.fruitConfirmById(fruitPO);
    }

}

